package LeetCode;

import java.util.Collection;
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingDeque;

public class _225_用队列实现栈 {
	private Queue<Integer> inQueue;
	private Queue<Integer> outQueue;
	
	public _225_用队列实现栈() {
		this.inQueue = new LinkedList<Integer>();
		this.outQueue = new LinkedList<Integer>();
	}
	
	 /** Push element x onto stack. */
    public void push(int x) {
    	inQueue.offer(x);
    	while (!outQueue.isEmpty()) {
			inQueue.offer(outQueue.poll());
		}
    	Queue<Integer> tempQueue = new LinkedList<Integer>();
    	tempQueue = inQueue;
    	inQueue = outQueue;
    	outQueue = tempQueue;
    }
    
    /** Removes the element on top of the stack and returns that element. */
    public int pop() {
    	return outQueue.poll();
    }
    
    /** Get the top element. */
    public int top() {
        return outQueue.peek();
    }
    
    /** Returns whether the stack is empty. */
    public boolean empty() {
        return outQueue.isEmpty();
    }
	    

	    
//	    public int pop() {
//	        return b.poll();
//	    }
//	   
//	    public int top() {
//	        return b.peek();
//	    }
//	    
//	    public boolean empty() {
//	        return b.isEmpty();
//	    }

	
}
